// source
let mut ret = Vec::new();
- for source in self.sources.sources_mut() {
+ for (_, source) in self.sources.sources_mut() {
try!(source.download(package_ids));
let packages = try!(source.get(package_ids));
// Ensure the requested source_id is loaded
try!(self.ensure_loaded(dep.get_source_id()));
let mut ret = Vec::new();
- for src in self.sources.sources_mut() {
- ret.extend(try!(src.query(dep)).into_iter());
+ for (id, src) in self.sources.sources_mut() {
+ if id == dep.get_source_id() {
+ ret.extend(try!(src.query(dep)).into_iter());
+ }
}
ret
} else {
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source+'src>>;
pub type SourcesMut<'a, 'src> = iter::Map<'static, (&'a SourceId,
&'a mut Box<Source+'src>),
- &'a mut (Source+'src),
+ (&'a SourceId, &'a mut (Source+'src)),
MutEntries<'a, SourceId, Box<Source+'src>>>;
impl<'src> SourceMap<'src> {
}
pub fn sources_mut<'a>(&'a mut self) -> SourcesMut<'a, 'src> {
- self.map.iter_mut().map(|(_, v)| &mut **v)
+ self.map.iter_mut().map(|(k, v)| (k, &mut **v))
}
}
use std::io::{mod, fs, File};
+use url::Url;
use git2;
+use support::path2url;
+
pub struct RepoBuilder {
repo: git2::Repository,
files: Vec<Path>,
self.repo.commit(Some("HEAD"), &sig, &sig,
"Initial commit", &tree, &[]).unwrap();
}
+
+ pub fn url(&self) -> Url { path2url(self.repo.path().dir_path()) }
}
use support::{UPDATING, DOWNLOADING, COMPILING, PACKAGING, VERIFYING};
use support::paths::{mod, PathExt};
use support::registry as r;
+use support::git;
use hamcrest::assert_that;
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url()).as_slice()));
})
+
+test!(git_and_registry_dep {
+ let b = git::repo(&paths::root().join("b"))
+ .file("Cargo.toml", r#"
+ [project]
+ name = "b"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ a = "0.0.1"
+ "#)
+ .file("src/lib.rs", "");
+ b.build();
+ let p = project("foo")
+ .file("Cargo.toml", format!(r#"
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ a = "0.0.1"
+
+ [dependencies.b]
+ git = '{}'
+ "#, b.url()))
+ .file("src/main.rs", "fn main() {}");
+ p.build();
+
+ r::mock_pkg("a", "0.0.1", &[]);
+
+ p.root().move_into_the_past().unwrap();
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
+ execs().with_status(0).with_stdout(format!("\
+{updating} [..]
+{updating} [..]
+{downloading} a v0.0.1 (registry file://[..])
+{compiling} a v0.0.1 (registry [..])
+{compiling} b v0.0.1 ([..])
+{compiling} foo v0.0.1 ({dir})
+", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
+ dir = p.url()).as_slice()));
+ p.root().move_into_the_past().unwrap();
+
+ println!("second");
+ assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
+ execs().with_status(0).with_stdout(""));
+})